package com.iran.flyWeight.example;

import com.iran.flyWeight.ConcreteFlyWeight;

import java.util.concurrent.ConcurrentHashMap;

public class WebSiteFactory {
    private ConcurrentHashMap<String,Object> flyWeights = new ConcurrentHashMap();
    public WebSite getWebSite(String key){
        if (!flyWeights.containsKey(key)){
            flyWeights.put(key,new ConcreteWebSite(key));
        }
        return (WebSite) flyWeights.get(key);
    }

    public int getWebSiteCount(){
        return (int) flyWeights.mappingCount();
    }
}
